package com.ds.dsm.view.config.form.field;

import com.ds.dsm.view.config.action.FieldAction;
import com.ds.dsm.view.config.form.service.FormFieldService;
import com.ds.esd.custom.ComboBoxBean;
import com.ds.esd.custom.annotation.CustomAnnotation;
import com.ds.esd.custom.annotation.FieldAnnotation;
import com.ds.esd.custom.grid.annotation.GridAnnotation;
import com.ds.esd.custom.grid.annotation.GridRowCmd;
import com.ds.esd.custom.grid.annotation.PageBar;
import com.ds.esd.custom.grid.annotation.RowHead;
import com.ds.esd.custom.grid.enums.GridMenu;
import com.ds.esd.dsm.view.field.FieldFormConfig;
import com.ds.esd.tool.ui.enums.ComboInputType;
import com.ds.esd.tool.ui.enums.ComponentType;
import com.ds.esd.tool.ui.enums.SelModeType;
import com.ds.esd.tool.ui.enums.TagCmdsAlign;

@PageBar(pageCount = 100)
@RowHead(selMode = SelModeType.none, gridHandlerCaption = "排序|隐藏", rowHandlerWidth = "8em", rowNumbered = false)
@GridRowCmd(tagCmdsAlign = TagCmdsAlign.left,menuClass = {FieldAction.class})
@GridAnnotation( customService = {FormFieldService.class}, customMenu = {GridMenu.Reload})
public class FieldFormInfo {

    @CustomAnnotation(pid = true, hidden = true)
    String viewInstId;
    @CustomAnnotation(pid = true, hidden = true)
    String domainId;
    @CustomAnnotation(caption = "字段名", readonly = true, uid = true)
    private String fieldname;

    @CustomAnnotation(caption = "中文名", readonly = true)
    private String caption;

    @FieldAnnotation(required = true)
    @CustomAnnotation(caption = "控件类型")
    private ComponentType componentType;

    @CustomAnnotation(caption = "字段类型")
    private ComboInputType inputType;


    @CustomAnnotation(hidden = true, pid = true)
    public String entityClassName;
    @CustomAnnotation(hidden = true, pid = true)
    public String sourceClassName;


    public FieldFormInfo(FieldFormConfig esdField) {
        this.viewInstId = esdField.getViewInstId();
        this.domainId = esdField.getDomainId();
        this.caption = esdField.getAggConfig().getCaption();
        this.fieldname = esdField.getFieldname();
        if (caption == null || caption.equals("")) {
            caption = fieldname;
        }
        componentType = esdField.getWidgetConfig().getType();
        this.sourceClassName = esdField.getSourceClassName();
        this.entityClassName = esdField.getEntityClassName();
        this.componentType = esdField.getAggConfig().getComponentType();

        if (esdField.getWidgetConfig() instanceof ComboBoxBean) {
            this.inputType = ((ComboBoxBean) esdField.getWidgetConfig()).getComboInputType()[0];
        }


    }

    public String getViewInstId() {
        return viewInstId;
    }

    public void setViewInstId(String viewInstId) {
        this.viewInstId = viewInstId;
    }

    public String getDomainId() {
        return domainId;
    }

    public void setDomainId(String domainId) {
        this.domainId = domainId;
    }

    public String getFieldname() {
        return fieldname;
    }

    public void setFieldname(String fieldname) {
        this.fieldname = fieldname;
    }

    public String getEntityClassName() {
        return entityClassName;
    }

    public void setEntityClassName(String entityClassName) {
        this.entityClassName = entityClassName;
    }

    public String getSourceClassName() {
        return sourceClassName;
    }

    public void setSourceClassName(String sourceClassName) {
        this.sourceClassName = sourceClassName;
    }

    public String getCaption() {
        return caption;
    }

    public void setCaption(String caption) {
        this.caption = caption;
    }

    public ComponentType getComponentType() {
        return componentType;
    }

    public void setComponentType(ComponentType componentType) {
        this.componentType = componentType;
    }

    public ComboInputType getInputType() {
        return inputType;
    }

    public void setInputType(ComboInputType inputType) {
        this.inputType = inputType;
    }
}
